qui(
    function (require, exports, module) {
        VOD.Plugin = $.extend(true, {}, EpgWeb.Plugin, {
            tips: (function () {
                var str = '<div class="alert alert-dismissible" role="alert1" style="display: inline;text-align: center;width: 420px">'
                    + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'
                    + '<span id="tips">{{cnt}}</span><strong style="margin-right:30px;">【3秒后自动关闭】</strong>'
                    + '</div>';
                var _timeId = null;

                return function (func, content) {
                    //移除旧对象
                    $("div[role=alert1]").remove();
                    if (_timeId) {
                        clearTimeout(_timeId);
                    }
                    var html = str;
                    html = html.replace(/{{cnt}}/g, content);
                    $(html).appendTo($(document.body));
                    //重新获取
                    var targetElement = $("div[role=alert1]");
                    targetElement.css("left", $(document.body).width() / 2 - $("div[role=alert1]").width() / 2);

                    if (func !== undefined) {
                        if (func == "success") {
                            targetElement.removeClass("alert-danger");
                            targetElement.addClass("alert-success");
                        }
                        else if (func == "error") {
                            targetElement.removeClass("alert-success");
                            targetElement.addClass("alert-danger");
                        }

                        _timeId = setTimeout(function(){
                            $('div[role=alert1]').find("button").trigger("click");
                        }, 3000);
                    }
                    else {
                        console.log("func is not exists!");
                    }
                };
            })(),
            Validate: (function () {
                var reg1 = /^\d+$/;
                var reg3 = /^[1-9]\d*$/;
                var reg2 = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
                var reg4 = /^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
                var checkObj = {
                    self_design: function (checkData, checkValue) {
                        return checkData.checkCall(checkData, checkValue)
                    },
                    date: function (checkData, checkValue) {
                        return checkDateFormat(checkValue);
                    },
                    not_empty: function (checkData, checkValue) {
                        return checkValue != null && $.trim(checkValue).length > 0;
                    },
                    eq: function (checkData, checkValue) {
                        return checkValue === checkData.other;
                    },
                    ne: function (checkData, checkValue) {
                        return checkValue !== checkData.other;
                    },
                    ge: function (checkData, checkValue) {
                        return  checkValue >= checkData.other;
                    },
                    gt: function (checkData, checkValue) {
                        return  checkValue > checkData.other;
                    },
                    lt: function (checkData, checkValue) {
                        return checkValue < checkData.other;
                    },
                    le: function (checkData, checkValue) {
                        return checkValue <= checkData.other;
                    },
                    positive: function (checkData, checkValue) {
                        return  checkPositive(checkValue)
                    },

                    number: function (checkData, checkValue) {
                        return checkNum(checkValue);
                    },
                    endsWith: function (checkData, checkValue) {
                        return checkValue != null && typeof(checkValue) == "string" && checkValue.slice(-(checkData.other.length)) == checkData.other;
                    }
                }

                function checkNum(checkString) {
                    return reg1.test(checkString)
                }

                function checkDateFormat(checkString) {
                    return reg2.test(checkString)
                }

                function checkPositive(checkString) {
                    return reg3.test(checkString)
                }

                function defaultHandler(msg) {
                    VOD.Plugin.tips("error", msg);
                }

                function batchCheck(checkArr) {
                    if (checkArr == null) {
                        checkArr = [];
                    }
                    if (checkArr.length == 0) {
                        return true;
                    }
                    var flag = false;
                    $.each(checkArr, function (index, checkData) {
                        flag = baseCheck(checkData);
                        if (!flag) {
                            return false;
                        }
                    })
                    return flag;
                }

                function baseCheck(checkData) {
                    var flag = false;
                    //$.isArray(checkData.value )
                    if (!(checkData.value instanceof Array)) {
                        checkData.value = [checkData.value];
                    }
                    //$.isArray(checkData.error )
                    if (!(checkData.error instanceof Array)) {
                        checkData.error = [checkData.error];
                    }
                    if (checkData.handler == null) {
                        checkData.handler = defaultHandler;
                    }
                    $.each(checkData.value, function (index, checkValue) {
                        if (checkObj.hasOwnProperty(checkData.type)) {
                            flag = checkObj[checkData.type](checkData, checkValue);
                        }
                        if (!flag) {
                            var hint = checkData.error.length == checkData.value.length ? checkData.error[index] : checkData.error[0];
                            checkData.handler(hint);
                            return false;
                        }
                    })
                    return flag
                }

                return {
                    baseCheck: baseCheck,
                    batchCheck: batchCheck,
                    checkDateFormat: checkDateFormat,
                    checkNum: checkNum
                }
            })()
        })

    }
);